<template>
 <textarea ref="editor"></textarea>
</template>

<script>
import SimpleMde from 'simplemde'
export default {
    props:{
        Value:String
    },
    data() {
        return {
            simplemde:null,
        }
    },
    mounted(){
        this.simplemde=new SimpleMde({ element: this.$refs.editor,spellChecker: false,});
        //监听change事件
        this.simplemde.codemirror.on('change',this.handleInput)
        this.Value && this.simplemde.value(this.Value)
},
    methods:{
    handleInput()
    {
        this.$emit("input",this.simplemde.value())
    }
},
    watch:{
        Value(val){
            val !== this.simplemde.value() && this.simplemde.value(val)
        }
    }
}
</script>

<style src="simplemde/dist/simplemde.min.css">
    
</style>


